import { http } from "@/utils/http";

// 获取报警列表
export const getListAPI = data => {
  return http.request("post", "/energy/consumptionMonitor/listAlarm", {
    data
  });
};

// 删除报警
export const deleteListDataAPI = data => {
  return http.request("post", "/energy/consumptionMonitor/deleteAlarm", {
    data
  });
};

// 关联分析--消耗量
export const getRelatedAnalysisDataAPI = data => {
  return http.request("post", "/energy/consumptionMonitor/viewAlarmCorrelationAnalysis", {
    data
  });
};

// 关联分析--消耗量--基准线
export const getSpcThresholdLineAPI = data => {
  return http.request("post", "/energy/consumptionMonitor/spcThresholdLine", {
    data
  });
};

// 关联分析--温度
export const getRelatedTemperatureLineAPI = data => {
  return http.request("post", "/energy/consumptionMonitor/temperatureLine", {
    data
  });
};

// 下钻分析
export const getLowAnalysisDataAPI = data => {
  return http.request("post", "/energy/consumptionMonitor/viewAlarmDrillDown", {
    data
  });
};

// 历史报警
export const getHistoryAlarmDataAPI = data => {
  return http.request("post", "/energy/consumptionMonitor/viewAlarmHistory", {
    data
  });
};

// 保存发起整改
export const saveInitiateAPI = data => {
  return http.request("post", "/energy/consumptionMonitor/saveEventStart", {
    data
  });
};

// 保存关闭事件
export const saveCloseEventAPI = data => {
  return http.request("post", "/energy/consumptionMonitor/saveClosure", {
    data
  });
};

// 上传文件
export const uploadFileAPI = data =>
  http.request(
    "post",
    `/sharing/api/v1/file/upload`,
    { data },
    {
      headers: {
        noLoading: true,
        "content-type": "application/x-www-form-urlencoded"
      }
    }
  );

// 保存整改
export const saveReformingAPI = data => {
  return http.request("post", "/energy/consumptionMonitor/saveRectify", {
    data
  });
};

// 通过审核
export const passCheckAPI = data => {
  return http.request("post", "/energy/consumptionMonitor/saveApproval", {
    data
  });
};

// 获取事件处理信息
export const getEventLineAPI = data => {
  return http.request("post", "/energy/consumptionMonitor/viewAlarmEvent", {
    data
  });
};

// 预览
export const previewAPI = data => {
  return http.request(
    "post",
    "/energy/consumptionMonitor/preview",
    {
      data
    },
    {
      responseType: "blob"
    }
  );
};

// 查看智能分析报告
export const getAnalysisReportAPI = data => {
  return http.request("post", "/energy/consumptionMonitor/viewAlarmAnalysis", {
    data
  });
};

// 获取人员
export const getPersonListAPI = (data = { pageSize: 99999, page: 1 }) => {
  return http.request("post", "/account/api/v1/user/listPage", {
    data
  });
};
